capture noisily mkdir  "${results}/othergraphs"

use ${nc_clean_data}/combined_full_wide if dbm==11 | dbm==12 | dbm==1 | dbm==2 , clear
local b = 2
local w = 20
local donut = 8

***********Figure 2b: Distribution of Birthdates by Sample ************
graph twoway hist z if ${cyrs_1993_1998} ${r_frl} ${g_ming5} & inrange(z,-`w'-`donut',`w'+`donut'-1) & !inrange(z,-`donut',`donut'-1), color(gs6) lwidth(thin) width(`b') start(-28) freq discrete  ///
|| hist z if ${cyrs_1993_1998} ${r_frl} ${g_ming5} & inrange(z,-`donut',`donut'-1), width(`b') start(-28) ///
	color(gs6) lwidth(thin) xline(0, lcolor(gs6)) xtitle("Birthdate (Centered at Jan 1)") xlabel(#5) freq discrete
graph export ${results}/othergraphs/f2b_hist.pdf, as(pdf)



***********Figure A15: Student Outcome Index RD Estimates by Donut Size (North Carolina) ************
use ${results}/final_fa15, clear

gen l_ci95 = b_bcut -1.96*se_bcut
gen u_ci95 = b_bcut +1.96*se_bcut
destring donut, force replace

local covars = "x_cyr"
local samp1 = "r_frl"
local out = "indexf_testgradsusp"
local restrict = `"outcome=="`out'"  & covars=="`covars'" & wdays=="20" "'
set scheme s1manual

graph twoway rcap u_ci95 l_ci95 donut if sample=="`samp1'" & `restrict', color(black)  ///
		|| scatter b_bcut donut  if sample=="`samp1'" & `restrict', color(black) ///
		yline(0, lcolor(black)) legend(off) xlabels(#6) ///
		xtitle("Donut Size", size(*.8))
graph export ${results}/othergraphs/fa15.pdf, as(pdf) replace


***********Figure A16: Student Outcome Index RD Estimates by Bandwidth (North Carolina) ************
use ${results}/final_fa16, clear

gen l_ci95 = b_bcut -1.96*se_bcut
gen u_ci95 = b_bcut +1.96*se_bcut
destring wdays, force replace

local covars = "x_cyr"
local samp1 = "r_frl"
local out = "indexf_testgradsusp"

foreach out in indexf_testgradsusp ever_exitgrad  ever_susp  index_test  { //ever_exitgrad  r_sds m_sds
local restrict = `"outcome=="`out'"  & covars=="`covars'" "'

set scheme s1manual

graph twoway rcap u_ci95 l_ci95 wdays if sample=="`samp1'" & `restrict', color(black)  ///
		|| scatter b_bcut wdays  if sample=="`samp1'" & `restrict', color(black) ///
		yline(0, lcolor(black)) legend(off) ///
		xtitle("Bandwidth", size(*.8))
graph export ${results}/othergraphs/fa16.pdf, as(pdf) replace

***********Figure A20: Effect of Cash Transfer Eligibility on Student Test Score Index Across Grades (North Carolina) ************
use ${results}/final_fa20, clear
gen l_ci95 = b_bcut -1.96*se_bcut
gen u_ci95 = b_bcut +1.96*se_bcut
gen g = real(substr(outcome,strpos(outcome,"_")+4,.))
replace g = 9  if outcome=="ae_sds"
sort g

gen g_str = string(g)
replace g_str = "HS"  if outcome=="ae_sds"

replace outcome="mr_sds" if outcome=="ae_sds"
gen outcome0 = substr(outcome,1,strpos(outcome,"_")+3)
gen xx = strpos(outcome,"_")+4

local out = "mr_sds"
local covars = "x_cyr"
local d = "8"
local se = "clust_z"
local wdays = "20"
local samp1 = "r_frl"

local restrict = `"outcome0=="`out'"  & covars=="`covars'" & (restrict=="none" | restrict=="") "'

preserve
drop if g>10
encode g_str, gen(g_str0)
tab g_str0, nolab
set scheme s1manual
graph twoway rcap u_ci95 l_ci95 g_str0 if sample=="`samp1'" & `restrict', color(black) xlabels( #6, valuelabels) xscale(range(0.8 7.2)) ///
		|| scatter b_bcut g_str0  if sample=="`samp1'" & `restrict', color(black) xlabels( #6, valuelabels)  xscale(range(0.8 7.2))  yline(0, lcolor(black)) legend(off) ///
		xtitle("Grade") ytitle("RD Estimate")
graph export ${results}/othergraphs/fa20.pdf, as(pdf) replace
restore
